var e = s(require("../../../@babel/runtime/regenerator")),
  t = require("../../../@babel/runtime/helpers/objectSpread2"),
  r = require("../../../@babel/runtime/helpers/asyncToGenerator"),
  i = s(require("@/config/index")),
  n = s(require("@/config/page")),
  a = require("@/services/explain-line-service"),
  o = require("@/services/user-service"),
  u = require("@/utils/jump");
function s(e) {
  return e && e.__esModule ? e : { default: e };
}
Page({
  data: {
    background: "transparent",
    iconTheme: "white",
    position: !0,
    CDN: i.default.CDN,
    isLogin: !1,
    userInfo: {},
    options: {},
  },
  onLoad: function (e) {
    this.setData({ options: e }),
      wx.setNavigationBarColor({
        backgroundColor: "#ffffff",
        frontColor: "#ffffff",
      });
  },
  onShow: function () {
    this.setData({
      isLogin: (0, o.getLoginStatus)(),
      userInfo: (0, o.getUserInfo)(),
    });
  },
  onLogin: function (i) {
    var o = this;
    return r(
      e.default.mark(function r() {
        var s, f, c, l, d, p, E, R, g, _, A, T;
        return e.default.wrap(function (e) {
          for (;;)
            switch ((e.prev = e.next)) {
              case 0:
                if (
                  (o.setData({ isLogin: !0, userInfo: i.detail }),
                  (s = o.data.options),
                  (f = s.redirectUrl),
                  (c = s.type),
                  (l = {
                    1: n.default.PAGE_KEFU_TRANSFER,
                    2: n.default.PAGE_EXPLAIN_TRANSFER,
                    3: n.default.PAGE_GUIDE_TRANSFER,
                    4: n.default.PAGE_ORDER_TRANSFER,
                    5: n.default.PAGE_COURSE_TRANSFER,
                    6: n.default.PAGE_VOLUNTEER_TRANSFER,
                    7: "zhishi",
                  }),
                  !f || !c)
                ) {
                  e.next = 11;
                  break;
                }
                if (
                  ((d = decodeURIComponent(f)),
                  (p = d.split("?")[0]),
                  (E = d.split("?")[1]),
                  (R = {}),
                  E)
                )
                  for (g = E.split("&"), _ = 0; _ < g.length; _++)
                    (A = g[_].split("=")), (R[A[0]] = A[1]);
                return (
                  (0, u.navigateTo)(l[c], t({ url: p }, R), !0),
                  e.abrupt("return")
                );
              case 11:
                if (!c || 99 !== Number(c)) {
                  e.next = 17;
                  break;
                }
                return (e.next = 14), (0, a.getExplainLineList)();
              case 14:
                return (
                  (T = e.sent)[1].active
                    ? wx.redirectTo({
                        url: ""
                          .concat(n.default.PAGE_TOUR_INDOOR_PATH, "?id=")
                          .concat(T[1].id),
                      })
                    : (0, u.navigateTo)(
                        "".concat(
                          n.default.PAGE_ORDER_TRANSFER,
                          "?url=plugin://order/audioGuide-page",
                        ),
                        {},
                        !0,
                      ),
                  e.abrupt("return")
                );
              case 17:
                wx.navigateBack();
              case 18:
              case "end":
                return e.stop();
            }
        }, r);
      }),
    )();
  },
});
